<?php
	
	//Start the session
	session_start();
	
 	//Get required classes
 	require_once("Common/DBConnection.php");
	require_once("Common/DBSettings.php");
	require_once("Common/Page.php");
	require_once("Common/LogHandler.php");
	require_once("Controller/PageMasterController.php");
	require_once("Controller/SkinController.php");
	require_once("view/PageView.php");

	//Create DBConnection and Connect
	$dbconnection = new DBConnection();
	$dbconnection->connect();
	
	//Create Page
    $page = new Page();
    
    //Create MasterController and do controll
    $masterController = new PageMasterController($dbconnection, DBsettings::DBPREFIX);
    $page = $masterController -> DoControll();
	
	//Create skinController and do controll
	$skinHandler = new SkinHandler();
	$skinController = new SkinController($skinHandler);
	$skinlinksDiv = $skinController->doControll();
	$skin = $skinHandler->getSkin();
	
	//Build our page
    $PageViewer = new PageView();
    $PageViewer->AddStyleSheet("css/css-reset.css");
    $PageViewer->AddStyleSheet("http://fonts.googleapis.com/css?family=Nova+Mono");
	$PageViewer->AddStyleSheet("css/" . $skin);	
	$PageViewer->AddStyleSheet("css/screen.css");
	$PageViewer->AddStyleSheet("css/" . $skin);

    //Echo out the rasult
	echo($PageViewer->GetXHTML10StrictPage($page->title, $page->body, $page->menu, $skinlinksDiv));

	//Close DB Connection
	$dbconnection->close();
?>